package com.guxingke.gblog.controller.back;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.guxingke.gblog.controller.BaseController;

@Controller
@RequestMapping("/manage/msg")
public class MsgManageController extends BaseController {

	@RequestMapping
	public ModelAndView list(HttpSession session) {
		ModelAndView mav = new ModelAndView();

		mav.addObject("msgs", msgService.getAll());
		mav.addObject("mainPage", "msg/manage-list.jsp");

		mav.setViewName("manage");
		return mav;
	}
	
	@RequestMapping("/delete")
	public String delete(
			@RequestParam(value = "msgId", required = true) Integer id,
			HttpServletRequest request, HttpSession session) {

		msgService.deleteMsg(id);
		
		return "redirect:/manage/msg.do";
	}
}
